home *** CD-ROM | disk | FTP | other *** search
- #ifndef lint
- static char rcsid[] = "$Header: mate.c,v 1.3 87/02/12 13:23:54 schoch Exp $";
- #endif
-
- /* mate.c */
-
- #include "externs.h"
-
- mate (pawnattempts, color)
- int pawnattempts;
- u_char color;
- {
- LIST l, tos, piecemoves ();
- int from, to;
-
- l = piecelocs [color];
- while (l != NIL) {
- from = l->i;
- l = l->n;
- tos = piecemoves (from, FALSE);
- while (tos != NIL) {
- to = tos->i;
- tos = tos->n;
- if (moveintocheck (from, to))
- continue;
- if (occupant [from] == PAWN
- && from % 10 != to % 10
- && pawnattempts > 3
- && option [ANNOUNCEPAWNS] == TRUE)
- continue;
- return FALSE;
- }
- }
- return TRUE;
- }
-
- insufficient ()
- {
- int i, p, minorpieces = 0;
- LIST l;
-
- for (i = 0; i < 2; i++) {
- l = piecelocs [i];
- while (l != NIL) {
- p = occupant [l->i];
- if (p == QUEEN || p == ROOK || p == PAWN)
- return FALSE;
- if (p == KNIGHT || p == BISHOP)
- minorpieces++;
- l = l->n;
- }
- }
- return (minorpieces <= 2);
- }
-